package com.keeson.android_cli.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.TextView;

import com.keeson.android_cli.R;


/**
 * 自定义加载进度对话框
 */
public class ShowDialog extends Dialog {

    private TextView mTvMsg;
    private ImageView img_icon;

    public ShowDialog(Context context) {
        super(context, R.style.dialogs);
        setContentView(R.layout.view_dialog_show);
        mTvMsg = findViewById(R.id.tv_text);
        img_icon = findViewById(R.id.img_icon);
        setCanceledOnTouchOutside(true);
        setCancelable(true);
    }


    public ShowDialog setMessage(String message) {
        mTvMsg.setText(message);
        return this;
    }

    public ShowDialog setResource(int resource) {
        img_icon.setBackgroundResource(resource);
        return this;
    }

    @Override
    public void show() {
        super.show();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                dismiss();
            }
        },5000);
    }
}
